package com.example.apiservice.interceptors;

import com.example.common.utils.RoleContext;
import com.example.common.utils.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;

public class UserInfoInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        String userId = UserContext.getUser();
        String role = RoleContext.getRole();
        if (userId != null) {
            template.header("user-info", userId.toString());
        }
        if (role != null) {
            template.header("role-info", role.toString());
        }
    }
}
